home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 27 / CU Amiga Magazine's Super CD-ROM 27 (1998)(EMAP Images)(GB)[!][issue 1998-10].iso / GoodBye / JohnKennedy / February96.lha / MASTERCLASS / AREXX / REXXARC.LHA / FindDups.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1996-02-01  |  1.5 KB  |  91 lines

  1. /* 
  2.     Search for duplicate file names 
  3.     © 1995 John Kennedy
  4. */
  5.  
  6. address command /* Use AmigaDOS */
  7.  
  8. /* First, generate list of files & sizes */
  9.  
  10. Say "Making list of all files in current directory...."
  11.  
  12. 'list lformat "%n %l %p" all files > t:templist'
  13.  
  14.  
  15.  
  16. /* Now, go though searching for duplicates */
  17.  
  18. Say "Searching for duplicates...."
  19.  
  20. infile1='infile1'
  21. infile2='infile2'
  22. outfile='outfile'
  23.  
  24. call open(outfile,'t:report','w')
  25.  
  26. call open(infile1,"t:templist",'r')
  27.  
  28. do while ~eof(infile1)
  29.     data1=readln(infile1)
  30.     parse var data1 name1 " " size1 " " path1
  31.  
  32.     call open(infile2,"t:templist",'r')
  33.     do while ~eof(infile2)
  34.  
  35.         data2=readln(infile2)
  36.         parse var data2 name2 " " size2 " " path2
  37.  
  38.         if ((name1=name2 & size1=size2) & (path1~=path2)) then do
  39.             call writeln(outfile,name1||" "||path1)
  40.         end
  41.     end
  42.     call close(infile2)
  43. end
  44. call close(infile1)
  45. call close(outfile)
  46.  
  47. /* Now process the report file a little further */
  48.  
  49. /* Let's start by sorting it... */
  50.  
  51. Say "Sorting report file..."
  52.  
  53. 'sort t:report t:report2'
  54.  
  55. /* Now display report, removing multiple files */
  56.  
  57. say
  58. say "Duplicate File Search Report"
  59. say "----------------------------"
  60. say
  61.  
  62. call open(infile1,"t:report2",'r')
  63.  
  64. name2=''
  65. path2=''
  66.  
  67. do while ~eof(infile1)
  68.     data1=readln(infile1)
  69.     parse var data1 name1 " " path1
  70.     
  71.     if (name1~=name2) then
  72.         say 
  73.  
  74.     if (name1~=name2 | path1~=path2) then
  75.         say path1||name1
  76.  
  77.     name2=name1
  78.     path2=path1
  79. end
  80.  
  81. call close(infile1)
  82.  
  83. /* All done! */
  84.  
  85. 'delete "t:report" quiet'
  86. 'delete "t:report2" quiet'
  87. 'delete "t:templist" quiet'
  88.  
  89. Say "All finished!"
  90.  
  91.